package org.gunncs.host;

import org.gunncs.command.Quitter;
import java.util.HashMap;

/**
 * A command call-able from the Shell, with any number of variables.
 * Commands have call-names, which are aliases for executing the command.
 * @author ajc
 */
public abstract class Command {

	private static HashMap<String, Command> instances;

	static {
		System.out.println("Initializing Commands...");
		instances = new HashMap<String, Command>();
		// create("Printer");

		System.out.println("exit, quit ...");
		addCommand(new Quitter(), "exit", "quit", "q");

		System.out.println("addition...");
//		addCommand()

	}

	private static void addCommand(Command c, String... names) {
		for (String s : names) {
			instances.put(s, c);
		}
	}

	// private static void addCommand(String[] name, Command c) {
	// for (String s : name) {
	// enums.put(s, c);
	// }
	// // enums.put(name, c);
	// }

	public static Command get(String com) {
		return instances.get(com);
	}

	// private static void create(String s) {
	// enums.put(s, new Command(s));
	// }

	// private String name;
	// private String name_format;

	// public Command() {
	//
	// }
	//
	// public Command(String name) {
	// this.name = name;
	// name_format = name + ":";
	// }

	// public class Listener {
	//
	// public void exception(Exception e) {
	// // TODO Auto-generated method stub
	//
	// }
	//
	// }

	public abstract void exec(String[] args);

	// {
	// console.printf(name_format, Arrays.toString(args) + "\n");
	// console.writer().println(Arrays.toString(args));
	// console.printf(name_format, "My work here is done \n");
	// console.writer().println("My work here is done");
	// // console.p
	// }

	// public String toString() {
	// return name;
	// }

}
